# coding=utf-8

"""
测试遍历 link list 的两种方法
"""


# Definition for singly-linked list.
class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None


def print_list(l):
    while l is not None:
        print l.val
        l = l.next


def print_list2(l):
    """这样错了"""
    while l.next is not None:
        l = l.next
        print l.val


if __name__ == "__main__":
    l1 = ListNode(9)
    _l1 = l1
    l1.next = ListNode(3)
    l1 = l1.next

    print_list(_l1)
    print_list2(_l1)
